this.name      = "harpoonNuke3"; 
this.author    = "eric walch"; 
this.copyright = "� 2008 the autors.";
this.description = "Nuke script";
this.version   = "1.0";

this.shipDied = function(whom, why)
{
    if (whom == this.ship.target && why == "scrape damage") this.penetrateHull()
	delete this.shipDied
}



this.penetrateHull = function()
{
	if (this.ship.target && Math.random() > 0.05)
	{
		var size = Math.pow(this.ship.target.mass, 0.33)/3
		var subMunition = this.ship.spawn("harpoonNukeSubMunition", 10)
		for (var i=0; i<subMunition.length; i++)
		{
			if (0 < oolite.compareVersion("1.73"))
			{
				subMunition[i].setPosition(this.ship.target.position.add(Vector3D.randomDirection(size)));
				subMunition[i].target = this.ship.target // fixed in 1.73
				subMunition[i].script.owner = this.ship.owner // attach owner to script, fixed in 1.73				
			}
			else 
			{
				subMunition[i].position = this.ship.target.position.add(Vector3D.randomDirection(size));
			}
		}
	}
}